<?php session_start(); 
include("confs/startShop.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Assn3_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>www.onestopjcu template</title>
<link href="Assn3_CSS.css" rel="stylesheet" type="text/css" />
<link href="shopping/shopping.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->

	<link href="Assn3_CSS.css" rel="stylesheet" type="text/css" />
	<link type="text/css" href="New folder/menu.css" rel="stylesheet" />
    <script type="text/javascript" src="New folder/jquery.js"></script>
    <script type="text/javascript" src="New folder/menu.js"></script>
    <script>
document.write('<div style="display:none;"><a href="http://apycom.com/">jQuery Menu by Apycom</a></div>');
</script>
</head>

<body>
<div class="container" id="top">

<div class="heads"><!-- heads -->
<div class="welcome">
<table>
<tr>
<td>
<?php  echo $_SESSION['msg2']; ?>
<a href="register.php"><?php  echo $_SESSION['msg1']; ?></a>
</td>
</tr>
</table>
</div>
</div>

<div id="menu">
  
  <ul class="menu1">
  		<li><a href="home.php" class="parent"><span>Home</span></a></li>
	
		<li><a href="member.php" class="parent"><span>Member</span></a>
			<div><ul>
    			<li><a href="member.php"><span>Member</span></a></li>            
				<li><a href="register.php"><span><?php  echo $_SESSION['msgMember']; ?></span></a></li>
    		
    		</ul></div>
		</li>           
        	
		<li><a href="Accommodation.php" class="parent"><span>Accommodation</span></a>
			<div><ul>           
				<li><a href="accommodation.php"><span>Search Room</span></a></li>
        		<li><a href="Accom_newpost.php"><span>Post New Advitisement</span></a></li>
            	<li><a href="viewpost.php"><span>View Your Posts</span></a></li>
       		
    		</ul></div>
		</li>	


		<li><a href="shopping.php" class="parent"><span>Selling Books</span></a>
			<div><ul>           
				<li><a href="shopping.php"><span>Browse Books</span></a></li>
           		<li><a href="shopping_newpost.php"><span>Post New Books</span></a></li>
             	<li><a href="view_cart.php"><span>View Your Carts</span></a></li>
       		   		
    		</ul></div>
	</li>



		<li><a href="announcement.php" class="parent"><span>Announcement</span></a>
			<div><ul>
    			<li><a href="announcement.php"><span>Announcement</span></a></li>           
        		<li><a href="new_announce.php"><span>Post New Announcement</span></a></li> 
            	<li><a href="viewmypost.php"><span>View Your Posts</span></a></li> 
                
    		</ul></div>
	</li>


        <li class="last"><a href="aboutus.php"><span>About us</span></a>
        	<div><ul>
            	<li><a href="feedback.php"><span>Feedback</span></a></li>
            </ul></div>
        
        </li>


<!-- InstanceBeginEditable name="phplogin" -->


<!-- InstanceEndEditable -->


</div><!-- menu -->


<!-- InstanceBeginEditable name="main" -->
<?php
	
	
	include("confs/config.php");
	
	$conn = mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD);
	mysql_select_db($DB_NAME, $conn);
	
	if (!isset($_REQUEST['search'])){
	
	$covers = mysql_query("SELECT id, cover FROM items WHERE qty != 0");
	} else {
		$price = (int)$_POST['price'];
		$covers = mysql_query("SELECT id, cover FROM  `items` WHERE `status` LIKE '".$_POST['status']."'  AND `name` LIKE '%".$_POST['title']."%' AND `price` <=".$price." AND `qty` !=0");

		if (mysql_numrows($covers) == 0)
		{
			$_SESSION['result'] = "No Records found.";
		}
	}
	$des = mysql_query("SELECT * FROM items");
?>

<script type="text/javascript" src="js/jquery.js"query.js"></script>
		<script type="text/javascript">
			$(document).ready(function () {
				$(".cover").hover(function () {
					
					$(".cover").css("border", "6px solid #ddd");
					$(this).css("border", "6px solid #D2C2A6");
					id = $(this).attr("id").replace(/cover\-/i, '');
					
					$(".des").hide();
					$("#des-" + id).show();
					
				}, function() {
					//
				});
				
				$(".cover").click(function() {
					id = $(this).attr("id").replace(/cover\-/i, '');
					
					show_dialog();
					$("#dialog-cover").html($("#cover-" + id).html());
					$("#dialog-des").html($("#des-" + id).html());
					$("#add-to-cart").attr("href", "actions.php?id=" + id + "&do=add_to_cart");
				});
				
				$("#overlay").click(function() {
					hide_dialog();
				});
				$("#dialog-close").click(function () {
					hide_dialog();
					return false;
				});
			});
			
			function show_dialog() {
				$("#overlay").fadeIn("fast");
				$("#dialog").fadeIn("fast");
			}
			
			function hide_dialog() {
				$("#overlay").fadeOut("fast");
				$("#dialog").fadeOut("fast");
			}
		</script>
		
<div class="main2">
<div class="user" style="margin-top:30px;">

<form action="" method="post">
		<table>
			<tr>
				<td>Book Title </td>
				<td><input type="text" name="title" value="<?php echo $title; ?>"/></td>
			</tr>
			<tr>

				<td>Status</td>
				<td><select name="status">
				<option value="%">All</option>
				<option value="Second Hand" <?php if($status=='Second Hand') echo "selected='selected'";?>>Second Hand</option>
				<option value="Brand New"  <?php if($status=='Brand New') echo "selected='selected'";?>>Brand New</option>


				</select></td>
			</tr>

			<tr>
				<td>Max Price: </td>
				<td><select name="price">
				<option value="1000000">Any Price</option>
				<option value="20"  <?php if($price=='20') echo "selected='selected'";?>>$20</option>
				<option value="40" <?php if($price=='40') echo "selected='selected'";?>>$40</option>
				<option value="60" <?php if($price=='60') echo "selected='selected'";?>>$60</option>
				</select></td>
			</tr>
			<tr>
				<td><input type="submit" value="SEARCH" name="search" /></td>
			</tr>
		</table>
	</form>
</div>


<div class="adv">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="725" height="150" id="FlashID" title="i like it">
    <param name="movie" value="proj 2 flash/proj2flash.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="opaque" />
    <param name="swfversion" value="11.0.0.0" />
    <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don't want users to see the prompt. -->
    <param name="expressinstall" value="Scripts/expressInstall.swf" />
    <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="proj 2 flash/proj2flash.swf" width="725" height="150">
      <!--<![endif]-->
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="swfversion" value="11.0.0.0" />
      <param name="expressinstall" value="Scripts/expressInstall.swf" />
      <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
      <div>
        <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
      </div>
      <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>
</div>

<div id="main_title">
	<h4 style="margin-top:5px; margin-bottom:10px;">Books</h4>
	</div>
    

<div id="content" style="margin-top:20px;">
<div id="mainleft">
				
			
				<div id="list">
					
					<?php
						while($row = mysql_fetch_assoc($covers)) {
							$id = $row['id'];
						
							if(file_exists("covers/".$row['cover']) && !is_dir("covers/".$row['cover'])) {
								$cover = "covers/".$row['cover'];
							} else {
								$cover = "covers/no.jpg";
							}
							
							echo "<div class='cover' id='cover-$id'><img src='$cover' width='120' height='144' /></div>";
						}
					
 if (isset($_SESSION['result'])) { 
	echo $_SESSION['result'];
unset($_SESSION['result']); }

					?>
					
				</div>
		</div>
				<div id="sidebar">
				
					<div id="cart">
					<?php error_reporting (E_ALL ^ E_NOTICE); ?>
						<?php if(count($_SESSION['cart']) > 0){?>
						
						<?php
							foreach($_SESSION['cart'] as $id => $qty) {
								$total += $qty;
							}
							echo "<a href='view_cart.php'><span>$total</span> books in your cart</a>";
						?>
						
					

						<?php } else { ?>
						
							Your cart is empty!
							
						<?php } ?>
					</div>
					
					<div id="des">
					
						<?php
							while($row = mysql_fetch_assoc($des)) {
								$id = $row['id'];
							
								echo "<div class='des' id='des-$id' style='display:none; font-family: Arial;
font-size: 13px;'>";
								echo "<h2>" . $row['name'] . " ($" . $row['price'] . ")</h2>";
								echo "<p>" . $row['des'] . "</p>";
								echo "<p>Quantity Available: " . $row['qty'] . " books for sale</p>";
								echo "</div>";
							}
						?>
					
					</div>
					
				</div>
</div>
            
<div id="overlay"></div>
<div id="dialog">
			<div id='dialog-cover'></div>
			<div id="dialog-des"></div>
			<div id="dialog-action">
				<a href="#" id='add-to-cart'>Add to Cart</a>
				<a href="#" id='dialog-close'>Close</a>
			</div>
		</div>


		
			


</div><!-- main -->
<!-- InstanceEndEditable -->


<div class="footer"> 
<div style="margin-left:10px; float:left; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px; color:#FFF; width:430px; height:12px; margin-top:16px;">Copyright &copy; 2012 www.onestopjcu.com
</div>

<div style="margin-left:50px; float:left; font-family:Arial, Helvetica,sans-serif; font-weight:bold; font-size:11px; width:100px; height:12px; margin-top:16px;"><a href="#top" style="color:#FFF; text-decoration: none;">Return to Top</a>
</div>

<ul>
<li><a href="feedback.php">Feedback</a></li>
<li><a href="FAQ.php">FAQ</a></li>
<li><a href="aboutus.php" style="margin-right:24px;">About Us</a></li>
<li><a href="aboutus.php" style="margin-right:24px;">Contact Us</a></li>
</ul>




</div><!-- footer -->
</div><!-- container -->
</body>
<!-- InstanceEnd --></html>
